﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Script.Serialization;
using DBUtil;
using DBUtil.Entity;

namespace DBUtilConsoleApp
{
    class MyClass : IConfigurationSectionHandler
    {

        #region IConfigurationSectionHandler 成员

        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            throw new NotImplementedException();
        }

        #endregion



    }

    public enum MyEnum
    {
        [EnumMember(Value = "2")]
        AA,
        [EnumMember(Value = "3")]
        BB
    }

    public static class MyClass1
    {


    }
    class Program
    {
        static void Main(string[] args)
        {
            //DBUtil.DB db = new DB(DataBaseType.MsSql);
            //DataTable data = new DataTable();

            //string sel_sql = "SELECT TOP 1000 * FROM dbo.Product ORDER BY id DESC";


            //data = db.QueryTable(sel_sql);

            //string whereStr = "where state=1";
            //string str = Regex.Replace(whereStr, @"(\s)*(where)(\s)+(.+)", "and $3$4", RegexOptions.Compiled | RegexOptions.IgnoreCase);
            //string orderby = "order by added desc";
            //string str1 = Regex.Replace(orderby, @"(\s)*(order)(\s)+(by)(.+)", "$5", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            //int totalCount = 0;
            //int pageIndex = 2;
            //int pageSize = 10;

            //data = db.GetDataTableByPager(pageIndex, pageSize, "*", "product a", "", "a.Id asc", out totalCount);





            //DB db = new DB(DataBaseType.Sqlite);
            //List<string> lsts = db.TableNames;




        }



        public class Customer
        {
            public string Name { get; set; }
            public int Age { get; set; }
            public bool Female { get; set; }
        }

        static void Chuan(dynamic c)
        {
            object obj = c;
            Type ty = obj.GetType();

            var dict = (IDictionary<string, object>)c;
            foreach (var entity in dict)
            {
                Console.WriteLine(entity.Key + "\t" + entity.Value);
            }
        }


        static void SWatch(Action act)
        {
            Stopwatch wat = new Stopwatch();
            wat.Start();
            act();
            wat.Stop();
            long lng = wat.ElapsedMilliseconds;

            Console.WriteLine(lng);
        }

        long SWatch(Action<object> act, object o)
        {
            Stopwatch wat = new Stopwatch();
            wat.Start();
            act(o);
            wat.Stop();
            return wat.ElapsedMilliseconds;
        }

        static void Test()
        {
            DB db = new DB(DataBaseType.MsSql);
            string sel_sql = string.Empty;
            DataTable dt = new DataTable();

            //sel_sql = "select top 10 * from product order by id desc";
            //dt = db.QueryTable(sel_sql);


            //db = new DBSession(DataBaseType.MySql);
            //sel_sql = "select * from product  order by id desc  limit  1,10 ";
            //dt = db.QueryTable(sel_sql);

            //db = new DBSession(DataBaseType.Oracle);
            //sel_sql = "Select  * From Cc_Qa Where Rownum<=10 Order By added Desc ";
            //dt = db.QueryTable(sel_sql);

            //db = new DBSession(DataBaseType.OracleManaged);
            //sel_sql = "Select  * From Cc_Qa Where Rownum<=10 Order By added Desc ";
            //dt = db.QueryTable(sel_sql);


            //db = new DBSession(DataBaseType.Sqlite);
            //sel_sql = "select * from base_datalog order by opertime desc limit 1,10";
            //dt = db.QueryTable(sel_sql);

            //db = new DBSession(DataBaseType.Oledb);
            //sel_sql = "Select  * From product  Order By settime Desc ";
            //dt = db.QueryTable(sel_sql);
        }

    }
}
